

import backgroulds from "./backgrould";
import mouseJs from "./mouse";
import allVariableJs from "./allVariable";
cc.Class({
    extends: cc.Component,

    properties: {
       
        continueBtn:cc.Button,
        againGameBtn:cc.Button,
        backMapBtn:cc.Button,
        backgrouldJs:backgroulds,
        voiceBtn:cc.Button,
        selectstate:cc.Boolean,
        mouse:mouseJs

        
    },


    voiceChange:function(){

       this.selectstate=!this.selectstate
       allVariableJs.SourceChange=this.selectstate
       if(this.selectstate==true){
        let that = this
        console.log("声音关")
          
        cc.loader.loadRes("syssoundoff2", cc.SpriteFrame, function (err, spriteFrame) {
            that.node.getChildByName('voiceBtn').getComponent(cc.Sprite).spriteFrame = spriteFrame;
        });

       }else{
        let that = this
        console.log("声音开")
        cc.loader.loadRes("syssoundon2", cc.SpriteFrame, function (err, spriteFrame) {
            that.node.getChildByName('voiceBtn').getComponent(cc.Sprite).spriteFrame = spriteFrame;
        });
       }

    },

    continueGameClick:function(){
    
        console.log("继续游戏");
        this.node.active=false
        this.backgrouldJs.startGame()
      

    },

   againGameClick:function(){
    console.log("重新开始游戏");
    cc.director.loadScene("GameSence");
   },

   backMapClick:function(){

    console.log("返回地图");
    cc.director.loadScene("StartGame");
   },


    onLoad () {

        this.selectstate=allVariableJs.SourceChange
        console.log("全局声音开关",allVariableJs.SourceChange)
        if(this.selectstate==true){
            let that = this
            console.log("声音关")
              
            cc.loader.loadRes("syssoundoff2", cc.SpriteFrame, function (err, spriteFrame) {
                that.node.getChildByName('voiceBtn').getComponent(cc.Sprite).spriteFrame = spriteFrame;
            });
    
           }else{
            let that = this
            console.log("声音开")
            cc.loader.loadRes("syssoundon2", cc.SpriteFrame, function (err, spriteFrame) {
                that.node.getChildByName('voiceBtn').getComponent(cc.Sprite).spriteFrame = spriteFrame;
            });
           }
        
    },

    start () {

    },

    // update (dt) {},
});
